package common

func Swap16(x uint16) uint16 {
	return (x << 8) | (x >> 8)
}

func Swap32(x uint32) uint32 {
	return ((x << 24) & 0xFF000000) |
		((x << 8) & 0x00FF0000) |
		((x >> 8) & 0x0000FF00) |
		((x >> 24) & 0x000000FF)
}

func Swap64(x uint64) uint64 {
	return ((x << 56) & 0xFF00000000000000) |
		((x << 40) & 0x00FF000000000000) |
		((x << 24) & 0x0000FF0000000000) |
		((x << 8) & 0x000000FF00000000) |
		((x >> 8) & 0x00000000FF000000) |
		((x >> 24) & 0x0000000000FF0000) |
		((x >> 40) & 0x000000000000FF00) |
		((x >> 56) & 0x00000000000000FF)
}
